#! /bin/bash
TIMENOW=$(date '+%Y%m%d%H%M%S')
WORK_PATH="/home/cicd/docker_webhook/cicd-back"
cd $WORK_PATH
echo "clean old code..."
git reset --hard origin/master
git clean -f
echo "pull latest code..."
git pull origin master
echo "start build 镜像"
docker build -t cicd-back:v${TIMENOW} . 
echo "stop and destroy old container..."
docker stop cicd-back-container
docker rm cicd-back-container
echo "start new 容器..."
docker container run -p 3666:3666 --name cicd-back-container -d cicd-back:v${TIMENOW}
